<div id="content" style="background-color:#ffffff">
  <div id="content-header">
    <div id="breadcrumb"> <a href="?m=admin&t=main" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 后台首页</a> <a href="#">问题模块设置</a> <a href="#" class="current">角色</a> </div>
  </div>
  <div class="container-fluid">
    <div class="row-fluid">
        <fieldset class="layui-elem-field">
          <legend>角色</legend>
          <div class="layui-field-box">
         
            <form id="form-wizard" class="layui-form" method="post" action="?m=admin&o=questionsite&t=saverole&id=<{$gvar.fget.id}>">
             
                 <div class="layui-form-item">
                    <label class="layui-form-label">角色名称</label>
                    <div class="layui-input-block">
                      <input type="text" name="name" value="<{$data.0.name}>" lay-verify="required" autocomplete="off" placeholder="请输入门店名称" class="layui-input">
                    </div>
                  </div>
				  <{if $data.0.level==2}>
				  <div class="layui-form-item layui-form-text">
					  <label class="layui-form-label">一级角色</label>
					  <div class="layui-input-block">
						  <select name="parent_id" id='province' lay-filter="province">
							 <option value='0'>请选择角色</option>
							 <{foreach from=$rolelist key=myId_2 item=menu_2}>
								<option value="<{$menu_2.id}>" <{if $menu_2.id==$data.0.parent_id}>selected<{/if}>><{$menu_2.name}></option>
							 <{/foreach}>
						  </select>
					  </div>
					</div><input type='hidden' name="level" value="2" lay-verify="required" autocomplete="off"  class="layui-input">
					<{else}><input type='hidden' name="level" value="1" lay-verify="required" autocomplete="off"  class="layui-input"><{/if}>
                  <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-block">
                      <textarea placeholder="请输入内容"  name="note" class="layui-textarea"><{$data.0.note}></textarea>
                    </div>
                  </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                 
                </div>
              </div>
            </form>
          </div>
        </fieldset>
</div>
<script>
layui.use(['form','tree','layer'], function(){
  var form = layui.form();
  var layer = layui.layer;
  form.on('select(province)', function(data){
	  var province = $('#province').val();
      $.ajax({
		   type: "POST",
		   url: "index.php?m=admin&o=questionsite&t=city",
		   dataType:"json",
		   data: {province:province},
		   success: function(msg){
			var msg = JSON.stringify(msg);
			msg = JSON.parse(msg);
			//console.log(aaa);
			var str = '';
			for (var key in msg){
				var str = str+"<option value='"+msg[key]['id']+"'>"+msg[key]['name']+"</option>";
			}
			$("#city").html("<option value='0' >选择市</option>");
			$("#city").append(str);
			form.render();
		   }
		});
  });
    form.on('select(city)', function(data){
	  var city = $('#city').val();
      $.ajax({
		   type: "POST",
		   url: "index.php?m=admin&o=questionsite&t=country",
		   dataType:"json",
		   data: {city:city},
		   success: function(msg){
			var msg = JSON.stringify(msg);
			msg = JSON.parse(msg);
			//console.log(aaa);
			var str = '';
			for (var key in msg){
				var str = str+"<option value='"+msg[key]['id']+"'>"+msg[key]['name']+"</option>";
			}
			$("#country").html("<option value='0' >选择县区</option>");
			$("#country").append(str);
			form.render();
		   }
		});
  });
});
 
</script>